package org.sy.lab.Java7并发编程实战.四线程执行器.四运行多个任务并处理第一个结果;

import java.util.concurrent.Callable;

public class TaskValidator implements Callable<String> {
	private UserValidator validator;
	private String user;
	private String password;
	public TaskValidator(UserValidator validator, String user, String password) {
		this.validator = validator;
		this.user = user;
		this.password = password;
	}
	@Override
	public String call() throws Exception {
		if(!validator.validate(user, password)) {
			System.out.printf("%s: The user has not been found\n", validator.getName());
			throw new Exception("Errer validating user");
		}
		System.out.printf("%s: The user has been found\n", validator.getName());
		return validator.getName();
	}
}
